import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;

import com.acme.bankapp.Exception.OverdraftLimitExceededException;
import com.acme.bankapp.domain.bank.*;
import com.acme.bankapp.service.bank.*;


public class BankApplication {
	public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {		
		BankApplication app = new BankApplication();
		BankDataLoaderService load=new BankDataLoaderService();
		BankService bc=new BankService();
		Bank bank = bc.readBank();
		
		load.loader(bank, bc);
		app.modifyBank(bank);
		ArrayList<Client> clients=bank.getClients();
		for(Client client : clients){
			System.out.print(client);
		}		
	}
	
	private void modifyBank(Bank bank){
		ArrayList<Client> clients=bank.getClients();
		for(Client client: clients){
			try {
				client.getAccount().withdraw(138);
			} catch (OverdraftLimitExceededException e) {
				System.out.println("Maximum posible means: "+e.getAmount());
			}
		}
	}

}
